package com.dqhl.business.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dqhl.business.Base.BaseActivity;
import com.dqhl.business.R;
import com.dqhl.business.adapter.GoodsManagerPageAdapter;

/**
 * description: 商品分类管理 批量 位置
 * autour: guanluocang
 * date: 2016/11/6 15:05
 */
public class GoodsManagerRecordActivity extends BaseActivity implements View.OnClickListener {

    private Context context;
    private TextView tv_goodsTopTitle;
    private ImageView iv_goodsGoBack;
    private TextView tv_open;
    private TextView tv_forbid;
    private ViewPager vp_goodsManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods_managere_record);
        context = this;
        initView();
    }

    private void initView() {
        tv_goodsTopTitle = (TextView) findViewById(R.id.tv_goodsTopTitle);
        tv_goodsTopTitle.setText("商品分类");
        iv_goodsGoBack = (ImageView) findViewById(R.id.iv_goodsGoBack);
        tv_open = (TextView) findViewById(R.id.tv_open);
        tv_forbid = (TextView) findViewById(R.id.tv_forbid);
        vp_goodsManager = (ViewPager) findViewById(R.id.vp_goodsManager);

        tv_open.setOnClickListener(this);
        tv_forbid.setOnClickListener(this);
        iv_goodsGoBack.setOnClickListener(this);

        vp_goodsManager.setAdapter(new GoodsManagerPageAdapter(this.getSupportFragmentManager()));
        vp_goodsManager.setCurrentItem(0, true);
        vp_goodsManager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                switch (position) {
                    case 0:
                        tv_open.setTextColor(ContextCompat.getColor(GoodsManagerRecordActivity.this,R.color.daiqianshou));
                        tv_forbid.setTextColor(ContextCompat.getColor(GoodsManagerRecordActivity.this,R.color.main_textContent));
                        break;
                    case 1:
                        tv_open.setTextColor(ContextCompat.getColor(GoodsManagerRecordActivity.this,R.color.main_textContent));
                        tv_forbid.setTextColor(ContextCompat.getColor(GoodsManagerRecordActivity.this,R.color.daiqianshou));
                        break;
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_goodsGoBack:
                finish();
                break;
            case R.id.tv_open:
                vp_goodsManager.setCurrentItem(0,true);
                break;
            case R.id.tv_forbid:
                vp_goodsManager.setCurrentItem(1,true);
                break;
        }
    }

}
